package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.SystemMessageQueryObject;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.*;
import java.lang.reflect.Type;

@RestController
@RequestMapping("/systemMessages")
public class SystemMessageController {

    @Autowired
    private ISystemMessageService systemMessageService;


    /*查询某用户的系统消息,包括已读未读,时间倒序,要翻页*/
    @GetMapping()
    public  Object queryMessages(SystemMessageQueryObject qo){
        qo.setOrderBy("id desc");
        qo.setPageSize(8);
        return systemMessageService.query(qo);
    }

    /**
     * 标记为已读
     */
    @PostMapping
    public Object setRead(Long sid, Long userId, Integer type){
        systemMessageService.setRead(sid,userId,type);
        return new JSONResult();
    }



}
